package com.neteast.androidclient.contact.adapter;

import java.util.ArrayList;
import com.neteast.androidclient.contact.R;
import com.neteast.androidclient.contact.domain.Contact;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class SearchResultAdapter extends BaseAdapter{
	public ArrayList<Contact> data;
	public Context context;
	private LayoutInflater mInflater;
	
	public SearchResultAdapter(Context context, ArrayList<Contact> data){
		this.context = context;
		this.data = data;
		mInflater = LayoutInflater.from(context);
	}
	
	public int getCount() {
		return data.size();
	}

	public Object getItem(int position) {
		return data.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		if (data == null) {
			return null;
		}
		ViewHolder holder = new ViewHolder();
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.contact_card_item, parent,false);
			holder = new ViewHolder();
			holder.nameText = (TextView) convertView.findViewById(R.id.name);
			holder.nickNameText = (TextView) convertView.findViewById(R.id.nickName);
			holder.companyText = (TextView) convertView.findViewById(R.id.company);
			holder.positionText = (TextView) convertView.findViewById(R.id.position);
			holder.phoneText = (TextView) convertView.findViewById(R.id.phone);
			holder.emailText = (TextView) convertView.findViewById(R.id.email);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.nameText.setText("");
		holder.nameText.setText("");
		holder.nameText.setText("");
		holder.nameText.setText("");
		holder.nameText.setText("");
		holder.nameText.setText("");
		return convertView;
	}

	class ViewHolder{
		ImageView avatarImg;
		TextView nameText;
		TextView nickNameText;
		TextView companyText;
		TextView positionText;
		TextView phoneText;
		TextView emailText;
	}
}
